#!/bin/bash
#centos76 init  + docker-ce ntp 
yum update -y
yum install wget -y
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum install telnet net-tools ntp epel-release container-selinux -y
systemctl enable ntpd
systemctl start ntpd
ntpdate cn.pool.ntp.org
sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
sudo yum-config-manager \
  --add-repo \
  http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum -y install docker-ce-20.10.3 docker-ce-cli-20.10.3 containerd.io
sudo systemctl enable docker.service

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://uab34swy.mirror.aliyuncs.com"]
}
EOF
systemctl enable docker && systemctl restart docker
systemctl restart firewalld
firewall-cmd \
  --add-port=22/tcp \
  --add-port=80/tcp \
  --add-port=443/tcp \
  --permanent
firewall-cmd --reload
systemctl restart docker
cat > /etc/sysctl.d/k8s.conf << EOF
net.ipv4.ip_forward=1
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
vm.swappiness=0
vm.max_map_count=655360 
EOF

sysctl -p /etc/sysctl.d/k8s.conf

curl -L https://get.daocloud.io/docker/compose/releases/download/1.28.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

echo "end"